﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CommerceShoppingCart
{
    [Serializable]
    public class CartItem
    {
        private int _productID;
        private string _productName;
        private string _productImageUrl;
        private int _quantity;
        private double _price;
        private double _lineTotal;

        /// <summary>
        /// 创建一个新的购物车货物对象
        /// </summary>
        /// <param name="productID">产品ID</param>
        /// <param name="productName">产品名字</param>
        /// <param name="productImageUrl">产品图片链接</param>
        /// <param name="quantity">数量</param>
        /// <param name="price">价格</param>
        public void New(int productID,string productName,string productImageUrl,
            int quantity, double price)
        {
            _productID = productID;
            _productName = productName;
            _productImageUrl = productImageUrl;
            _quantity = quantity;
            _price = price;
        }
        /// <summary>
        /// 设置/取得产品的ID
        /// </summary>
        public int ProductID
        {
            get
            {
                return _productID;
            }
            set
            {
                _productID = value;
            }
        }
       
        /// <summary>
        /// 设置/取得产品的名字
        /// </summary>
        public string ProductName
        {
            get
            {
                return _productName;
            }
            set
            {
                _productName = value;
            }
        }

        /// <summary>
        /// 设置/取得产品的图片位置
        /// </summary>
        public string ProductImageUrl
        {
            get
            {
                return _productImageUrl;
            }
            set
            {
                _productImageUrl = value;
            }
        }
        /// <summary>
        /// 设置/取得购买了的数量
        /// </summary>
        public int Quantity
        {
            get
            {
                return _quantity;
            }
            set
            {
                _quantity = value;
            }
        }

        /// <summary>
        /// 设置/取得产品的价格
        /// </summary>
        public double Price
        {
            get
            {
                return _price;
            }
            set
            {
                _price = value;
            }
        }

        /// <summary>
        /// 产品的总的价格
        /// </summary>
        public double LineTotal
        {
            get
            {
                return _quantity * _price;
            }
        }
    }
}
